package xin.basic.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import xin.core.jpa.JpaConstant;
import xin.core.jpa.model.SimpleSortableEntity;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * <pre>
 * 数据字典分组
 * </pre>
 *
 * @author lixin_ma@outlook.com
 * @version 1.0
 * @since 2018/8/10
 */
@Entity
@Table(name = "sys_dict_group")
@EqualsAndHashCode(callSuper = true)
@Data
@ToString
@ApiModel
public class DictGroup extends SimpleSortableEntity {

    /**
     * 字典表分组编号。 手动输入
     */
    @Id
    @Column(length = JpaConstant.UidColumnLength)
    private String code;

    /**
     * 数据字典列表
     */
    @OneToMany(fetch = FetchType.EAGER)
    @JoinColumn(name = "groupCode")
    private List<Dict> dictList;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @Column()
    private Date createTime;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @Column()
    private Date lastModifyTime;

    @Column(length = JpaConstant.UidColumnLength, updatable = false)
    protected String createBy;

    @Column(length = JpaConstant.UidColumnLength, insertable = false)
    protected String lastModifyBy;
}
